import requests
import base64
def timecatch():
    try:
        hea = {'User-Agent': 'Mozilla/5.0'}
        url = r'http://time1909.beijing-time.org/time.asp'
        r = requests.get(url=url,headers=hea)
        if r.status_code == 200:
            beijin=r.text.split(";")
            year=beijin[1].split("=")[1]
            month=beijin[2].split("=")[1]
            day=beijin[3].split("=")[1]
            hour=beijin[5].split("=")[1]
            if(len(hour)==1):
                hour="0"+str(hour)
            mins=beijin[6].split("=")[1]
            if(len(mins)==1):
                mins="0"+str(mins)
            sec=beijin[7].split("=")[1]
            if(len(sec)==1):
                sec="0"+str(sec)
            rq="%s %s %s %s %s %s"%(year,month,day,hour,mins,sec)
            dqsj=rq.split(" ")
            for i in range(len(dqsj)):
                if(len(dqsj[i])==1):
                    dqsj[i]="0"+dqsj[i]
            dqsj="".join(dqsj)
            return dqsj
    except:
        print("获取在线时间失败，请检查电脑是否联网")
        input("点击换行继续...")
        quit()
zzsj=input("请输入一个key:")
zzsj=zzsj[3:-1].replace("{","=")
zzsj=base64.b64decode(zzsj[::-1].encode("UTF-8")).decode("UTF-8")
zzsj=str(int(zzsj[::-1].replace("{","="),16))[::-1]

kssj=""
gqsj=""
for i in range(0,len(zzsj),28):
    kssj+=str(zzsj[i])
for i in range(1,28,2):
    gqsj+=str(zzsj[i])

dqsj=timecatch()
if(dqsj>=kssj):
    if(dqsj<=gqsj):
        gqsj=list(gqsj)
        fh=["\\","\\"," ",":",":"]
        k=0
        for i in range(4,len(gqsj)+3,3):
            gqsj.insert(i,fh[k])
            k+=1
        print("体验卡结束日期为:"+"".join(gqsj))
    else:
        print("体验卡已过期")
else:
    print("体验卡已过期")
